-#
  Copyright 2008 Garth Williams

  This file is part of CommandPost.

  CommandPost is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  CommandPost is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with CommandPost.  If not, see <http://www.gnu.org/licenses/>.


%h1=h @homepage_content.title
=render_text @homepage_content.body
-if logged_in? and current_user.has_role?('PageAuthors')
  .align-right
    =link_to 'Edit', :controller => 'pages', :action => 'edit', :name => 'homepage_content'
  
- if logged_in?
  %h1 Latest Assignments

  - for report in @reports
    .report
      =link_to "#{h(report.name)} (#{h(report.stage.name)})", stage
      Assigned to
      - if report.assigned_to_user != nil
        = report.assigned_to_user.name
        - if report.stage.roles.length > 1
          = ", #{report.stage.roles.collection{|role| role.name}[0..-2].join(', ')}"
        - if report.stage.roles.length > 0
          = " and #{report.stage.roles[-1].name}"
      - else
        - if report.stage.roles.length > 1
          = "#{report.stage.roles.collection{|role| role.name}[0..-2].join(', ')} and"
        - if report.stage.roles.length > 0
          = "#{report.stage.roles[-1].name}"
      = "on #{render_date_time report.created_at} by #{report_created_by_user.name}"
  - if @reports.length == 0
    No reports are currently assigned to you
  
%h1 Upcoming Milestones

- for milestone in @milestones
  .milestone
    =link_to h(milestone.name), milestone
    - if milestone.due_by < Time.now
      %span.red (overdue)
    ="Due by #{render_date milestone.due_by}"
- if @milestones.length == 0
  No upcoming milestones
